package rpc_client

import (
	"context"

	"github.com/sirupsen/logrus"
	"github.com/smallnest/rpcx/client"
	"go.web.demo.com/api/entity"
	"go.web.demo.com/api/pojo"
)

var activityClient client.XClient

//初始化
func createActivityClient() {
	logrus.Info("创建ActivityClient")
	activityClient = client.NewXClient("ActivityService", client.Failtry, client.RandomSelect, discover, client.DefaultOption)
}

// CloseActivityClient 关闭客户端
func CloseActivityClient() {
	logrus.Info("关闭ActivityServiceClient")
	e := activityClient.Close()
	if e != nil {
		logrus.Error(e)
		panic(e)
	}
	activityClient = nil
}

// QueryOneActivity 查询用户
func QueryOneActivity(param *pojo.ActivityParam) *entity.Activity {
	activity := &entity.Activity{}
	e := activityClient.Call(context.Background(), "QueryOneActivity", param, activity)
	if e != nil {
		logrus.Error(e)
		panic(e)
	}
	return activity
}
